//
//  CanBtnView.m
//  KuWoCan
//
//  Created by hwd on 17/3/3.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "CanBtnView.h"

@implementation CanBtnView

-(UIView *)addBigBtnMainCG:(CGRect)frame Color:(NSString *)color ImageV:(NSString *)image Title:(NSString *)title
{

    self.frame = frame;
    self.backgroundColor = [UIColor colorWithHexString:color];
    [self.layer  setCornerRadius:2*screenW_6];
    self.layer.masksToBounds  = YES;
    
    CanImageView *centerImageV = [[CanImageView alloc]initWithFrame:CGRectMake(frame.size.width/4*1.5,frame.size.height/6, frame.size.width/4, frame.size.height/3) backGroundImageV:image];
    [self addSubview:centerImageV];
    
    CanLab *titleLab = [[CanLab alloc]initWithFrame:CGRectMake(10*screenW_6, CGRectGetMaxY(centerImageV.frame), frame.size.width-20*screenW_6,frame.size.height/3) textAligment:1 font:16*screenW_6 textColor:@"FFFFFF" text:title];
    [self addSubview:titleLab];
    
    UIButton *pushBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    pushBtn.backgroundColor = [UIColor clearColor];
    [pushBtn addTarget:self action:@selector(turnToNextVC) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:pushBtn];
    [pushBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(@0);
    }];
    
    return self;
}

- (void)turnToNextVC
{
    __weak typeof(self) weakSelf = self;
    if (_block) {
        _block(weakSelf.tag);
    }
}


-(UIView *)addSmallBtnMainCG:(CGRect)frame Color:(NSString *)color ImageV:(NSString *)image Title:(NSString *)title
{
    self.frame = frame;
    self.backgroundColor = [UIColor colorWithHexString:color];
    [self.layer  setCornerRadius:2*screenW_6];
    self.layer.masksToBounds  = YES;
    
    if ([title isEqualToString:@"产品陈列费用申请"]) {
        
        CanImageView *centerImageV = [[CanImageView alloc]initWithFrame:CGRectMake(frame.size.width-frame.size.height/2-frame.size.width/7,frame.size.height/4, frame.size.height/2, frame.size.height/2) backGroundImageV:image];
        [self addSubview:centerImageV];
        
        CanLab *titleLab = [[CanLab alloc]initWithFrame:CGRectMake(frame.size.width/8,frame.size.height/4, frame.size.width/2,frame.size.height/4) textAligment:1 font:16*screenW_6 textColor:@"FFFFFF" text:@"产品陈列"];
        [self addSubview:titleLab];
        
        CanLab *titleLab2 = [[CanLab alloc]initWithFrame:CGRectMake(frame.size.width/8,CGRectGetMaxY(titleLab.frame), frame.size.width/2,frame.size.height/4) textAligment:1 font:16*screenW_6 textColor:@"FFFFFF" text:@"费用申请"];
        [self addSubview:titleLab2];
        
        
    }else
    {
        CanImageView *centerImageV = [[CanImageView alloc]initWithFrame:CGRectMake(frame.size.width/8,frame.size.height/4, frame.size.height/2, frame.size.height/2) backGroundImageV:image];
        [self addSubview:centerImageV];
        
        CanLab *titleLab = [[CanLab alloc]initWithFrame:CGRectMake(frame.size.width/4,frame.size.height/4, frame.size.width/8*5,frame.size.height/2) textAligment:1 font:16*screenW_6 textColor:@"FFFFFF" text:title];
        [self addSubview:titleLab];
    }
    
    UIButton *pushBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    pushBtn.backgroundColor = [UIColor clearColor];
    [pushBtn addTarget:self action:@selector(turnToNextVC) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:pushBtn];
    [pushBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.equalTo(@0);
    }];
    
    return self;
}
-(UIView *)addOtherBtnMainCG:(CGRect)frame Color:(NSString *)color ImageV:(NSString *)image Title:(NSString *)title
{
    return self;
}
@end
